package com.lang.JsonConfig;

import com.alibaba.fastjson.serializer.JSONSerializer;
import com.alibaba.fastjson.serializer.ObjectSerializer;

import java.lang.reflect.Type;
import java.time.Duration;

public class DurationJsonSerializeUsing implements ObjectSerializer {
    @Override
    public void write(JSONSerializer serializer, Object object, Object fieldName, Type fieldType, int features) {
        Duration duration = (Duration) object;
        serializer.write(String.valueOf(duration.getSeconds()));
    }
}
